import 'package:flutter/material.dart';

class NavigatorDemo extends StatelessWidget {
  const NavigatorDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const TextButton(
              onPressed: null , 
              child: Text(
                'Home'
              ),
            ),
            TextButton(
              onPressed: () {
                Navigator.pushNamed(context, '/newsname');
              },
              // onPressed: () {
              //   Navigator.of(context).push(
              //     MaterialPageRoute(
              //       builder: (context) => const Pages(title: 'xinluyou',),
              //     ),
              //   );
              // },
              child: const Text(
                'About'
              ),
            ),
          ],
        ),
      ),
    );
  }
}


class Pages extends StatelessWidget {

  final String title;

  
  const Pages({super.key, this.title = '默认值'});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
        elevation: 0,
      ),
      floatingActionButton: FloatingActionButton(
        child: const Icon(
          Icons.arrow_back
        ),
        onPressed: () {
          Navigator.pop(context);
        },
      ),
    );
  }
}